home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / bit / src / jpeg / jinclude.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  4KB  |  115 lines

  1. /*
  2.  * jinclude.h
  3.  *
  4.  * Copyright (C) 1991, 1992, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This is the central file that's #include'd by all the JPEG .c files.
  9.  * Its purpose is to provide a single place to fix any problems with
  10.  * including the wrong system include files.
  11.  * You can edit these declarations if you use a system with nonstandard
  12.  * system include files.
  13.  */
  14.  
  15.  
  16. /*
  17.  * Normally the __STDC__ macro can be taken as indicating that the system
  18.  * include files conform to the ANSI C standard.  However, if you are running
  19.  * GCC on a machine with non-ANSI system include files, that is not the case.
  20.  * In that case change the following, or add -DNONANSI_INCLUDES to your CFLAGS.
  21.  */
  22.  
  23. #ifdef __STDC__
  24. #ifndef NONANSI_INCLUDES
  25. #define INCLUDES_ARE_ANSI    /* this is what's tested before including */
  26. #endif
  27. #endif
  28.  
  29. #ifndef INCLUDES_ARE_ANSI
  30. #define INCLUDES_ARE_ANSI    /* this is what's tested before including */
  31. #endif
  32. /*
  33.  * <stdio.h> is included to get the FILE typedef and NULL macro.
  34.  * Note that the core portable-JPEG files do not actually do any I/O
  35.  * using the stdio library; only the user interface, error handler,
  36.  * and file reading/writing modules invoke any stdio functions.
  37.  * (Well, we did cheat a bit in jmemmgr.c, but only if MEM_STATS is defined.)
  38.  */
  39.  
  40. #include <stdio.h>
  41.  
  42. /*
  43.  * We need the size_t typedef, which defines the parameter type of malloc().
  44.  * In an ANSI-conforming implementation this is provided by <stdio.h>,
  45.  * but on non-ANSI systems it's more likely to be in <sys/types.h>.
  46.  * On some not-quite-ANSI systems you may find it in <stddef.h>.
  47.  */
  48.  
  49. #ifndef INCLUDES_ARE_ANSI    /* shouldn't need this if ANSI C */
  50. #include <sys/types.h>
  51. #endif
  52. #ifdef __SASC            /* Amiga SAS C provides it in stddef.h. */
  53. #include <stddef.h>
  54. #endif
  55.  
  56. /*
  57.  * In ANSI C, and indeed any rational implementation, size_t is also the
  58.  * type returned by sizeof().  However, it seems there are some irrational
  59.  * implementations out there, in which sizeof() returns an int even though
  60.  * size_t is defined as long or unsigned long.  To ensure consistent results
  61.  * we always use this SIZEOF() macro in place of using sizeof() directly.
  62.  */
  63.  
  64. #undef SIZEOF            /* in case you included X11/xmd.h */
  65. #define SIZEOF(object)    ((size_t) sizeof(object))
  66.  
  67. /*
  68.  * fread() and fwrite() are always invoked through these macros.
  69.  * On some systems you may need to twiddle the argument casts.
  70.  * CAUTION: argument order is different from underlying functions!
  71.  */
  72.  
  73. #define JFREAD(file,buf,sizeofbuf)  \
  74.   ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  75. #define JFWRITE(file,buf,sizeofbuf)  \
  76.   ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  77.  
  78. /*
  79.  * We need the memcpy() and strcmp() functions, plus memory zeroing.
  80.  * ANSI and System V implementations declare these in <string.h>.
  81.  * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  82.  * Some systems may declare memset and memcpy in <memory.h>.
  83.  *
  84.  * NOTE: we assume the size parameters to these functions are of type size_t.
  85.  * Change the casts in these macros if not!
  86.  */
  87.  
  88. #ifdef INCLUDES_ARE_ANSI
  89. #include <string.h>
  90. #define MEMZERO(target,size)    memset((void *)(target), 0, (size_t)(size))
  91. #define MEMCOPY(dest,src,size)    memcpy((void *)(dest), (const void *)(src), (size_t)(size))
  92. #else /* not ANSI */
  93. #ifdef BSD
  94. #include <strings.h>
  95. #define MEMZERO(target,size)    bzero((void *)(target), (size_t)(size))
  96. #define MEMCOPY(dest,src,size)    bcopy((const void *)(src), (void *)(dest), (size_t)(size))
  97. #else /* not BSD, assume Sys V or compatible */
  98. #include <string.h>
  99. #define MEMZERO(target,size)    memset((void *)(target), 0, (size_t)(size))
  100. #define MEMCOPY(dest,src,size)    memcpy((void *)(dest), (const void *)(src), (size_t)(size))
  101. #endif /* BSD */
  102. #endif /* ANSI */
  103.  
  104.  
  105. /* Now include the portable JPEG definition files. */
  106.  
  107. #include "jconfig.h"
  108.  
  109. #include "jpegdata.h"
  110.  
  111. /* can be used to check if there is mem leak in jpg code */
  112. #ifdef M_DBG
  113. #include "../dmalloc.h"
  114. #endif
  115.